/*
 * ContactValidator.java
 *
 * Created on October 30, 2008, 1:30 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.vacuela.publishmx.domains.logic;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import org.vacuela.publishmx.domains.Contact;

/**
 *
 * @author nestor.carrasco
 */
public class ContactValidator implements Validator {
    
    public boolean supports(Class clazz) {
        return Contact.class.isAssignableFrom(clazz);
    }
    
    public void validate(Object obj, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "firstName", "CONTACT_FNAME_REQUIRED", "Contact First name is required.");
        ValidationUtils.rejectIfEmpty(errors, "lastName",  "CONTACT_LNAME_REQUIRED", "Contact Last name is required.");                
    }
    
}
